﻿using System;
using System.Windows;
using System.Windows.Controls;
using Cimbalino.Phone.Toolkit.Services;
using DepSoft.Mobile.WP8.FollwIt.Framework;
using DepSoft.Mobile.WP8.FollwIt.ViewModel;
using Microsoft.Phone.Controls;
using Microsoft.Practices.ServiceLocation;
using GestureEventArgs = System.Windows.Input.GestureEventArgs;

namespace DepSoft.Mobile.WP8.FollwIt.View.Shell
{
    public partial class LeftView : UserControl
    {
        public LeftView()
        {
            InitializeComponent();           
            TiltEffect.TiltableItems.Add(typeof(Border));
            this.DataContext = ServiceLocator.Current.GetInstance<MainViewModel>();
        }

        private void OnAccountClick(object sender, RoutedEventArgs e)
        {
            ServiceLocator.Current.GetInstance<INavigationService>().NavigateTo(Constants.LOGINURI);
        }

        private void OnMoviesClick(object sender, GestureEventArgs e)
        {
            Uri moviesPageUri = new Uri(string.Format("{0}?key={1}", Constants.MOVIESURI, ((MainViewModel)this.DataContext).FollwItUser.Username), UriKind.Relative);
            ServiceLocator.Current.GetInstance<INavigationService>().NavigateTo(moviesPageUri);
        }

        private void OnSeriesClick(object sender, GestureEventArgs e)
        {
            Uri seriesPageUri = new Uri(string.Format("{0}?key={1}", Constants.SERIESURI, ((MainViewModel)this.DataContext).FollwItUser.Username), UriKind.Relative);
            ServiceLocator.Current.GetInstance<INavigationService>().NavigateTo(seriesPageUri);
        }
    }
}
